<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>
		//es6允许按照一定模式,从数组和对象中提取值对变量进行赋值,这被称为解构赋值
		//数组的解构赋值，对象的解构赋值，函数的参数解构赋值（默认值）（批量的给变量赋值）

        let [d,e,f] = [1, 2, 3];
        console.log(d, e, f);

        //左边多，右少
	    //多出的变量值undefined	
        let [a, b, c] = ['html', 'css'];
        console.log(a, b, c);

        //左少，右多
	    //右侧多出的值，被舍弃
        let = [x, y] = ['html', 'css', 'js']
        console.log(x, y);

        function fun([a, b]) {
            console.log(a, b);
        }
        fun([1, 2])

        //有参数传入的时候，就用参数的值，没有参数传入就用默认值
        //默认值最好写在右侧
        function fn(a, b = 1) {
            console.log(a, b);
        }
        fn(4)

        var address = '是的撒';
        var obj = {
            name: '张三',
            age: 123,
            address
        }
        console.log(obj);
        var {age, name} = obj
        console.log(name, age);
    </script>
</body>
</html>